package com.js.mytransitiondemo.before;

// Created by JS on 2021/7/6.

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;

import com.js.mytransitiondemo.R;
import com.js.mytransitiondemo.databinding.ActivityBeforeTwoBinding;

public class BeforeTwoActivity extends AppCompatActivity {

    private ActivityBeforeTwoBinding binding;
    private int type;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityBeforeTwoBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        initData();
    }

    private void initData() {
        type = getIntent().getIntExtra("type", 1);
    }

    @Override
    public void onBackPressed() {
        finish();
        if (type == 1) {
            overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
            ActivityCompat.finishAfterTransition(this);
        } else if (type == 2) {
            overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
            ActivityCompat.finishAfterTransition(this);
        }
    }
}
